Derlerken Hata Görünmüyor Çalıştırınca Hata Verip Kapanıyor
Merhaba arkadaşlar android java programlamaya yeni giriyorum o yüzden basit sorunlarda takılabiliyorum. Yardımlarınız için şimdiden teşekkürler.
Programımın kodları şöyle[code]
package com.aek.btntest1;
import android.R.string;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.view.View.OnClickListener;
public class MainActivity extends ActionBarActivity {
Button btn1,btn2;
TextView yazi;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1= (Button) findViewById(R.id.button1);
btn2= (Button) findViewById(R.id.button2);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
yazi.setText("1.Butona Tıklandı");
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
yazi.setText("2.Butona Tıklandı");
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
[/code]
Derlerken herhangi bir hata almıyorum. AVD ile çalıştırıyorum butonlardan birine tıkladığımda uygulama durdu diyor kapanıyor. LogCat de şu yazılar geliyor.[code]08-27 03:21:04.627: D/gralloc_goldfish(1679): Emulator without GPU emulation detected.
08-27 03:21:15.277: D/AndroidRuntime(1679): Shutting down VM
08-27 03:21:15.277: W/dalvikvm(1679): threadid=1: thread exiting with uncaught exception (group=0xb2ae4ba8)
08-27 03:21:15.287: E/AndroidRuntime(1679): FATAL EXCEPTION: main
08-27 03:21:15.287: E/AndroidRuntime(1679): Process: com.aek.btntest1, PID: 1679
08-27 03:21:15.287: E/AndroidRuntime(1679): java.lang.NullPointerException
08-27 03:21:15.287: E/AndroidRuntime(1679): at com.aek.btntest1.MainActivity$1.onClick(MainActivity.java:30)
08-27 03:21:15.287: E/AndroidRuntime(1679): at android.view.View.performClick(View.java:4438)
08-27 03:21:15.287: E/AndroidRuntime(1679): at android.view.View$PerformClick.run(View.java:18422)
08-27 03:21:15.287: E/AndroidRuntime(1679): at android.os.Handler.handleCallback(Handler.java:733)
08-27 03:21:15.287: E/AndroidRuntime(1679): at android.os.Handler.dispatchMessage(Handler.java:95)
08-27 03:21:15.287: E/AndroidRuntime(1679): at android.os.Looper.loop(Looper.java:136)
08-27 03:21:15.287: E/AndroidRuntime(1679): at android.app.ActivityThread.main(ActivityThread.java:5017)
08-27 03:21:15.287: E/AndroidRuntime(1679): at java.lang.reflect.Method.invokeNative(Native Method)
08-27 03:21:15.287: E/AndroidRuntime(1679): at java.lang.reflect.Method.invoke(Method.java:515)
08-27 03:21:15.287: E/AndroidRuntime(1679): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-27 03:21:15.287: E/AndroidRuntime(1679): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-27 03:21:15.287: E/AndroidRuntime(1679): at dalvik.system.NativeStart.main(Native Method)
08-27 03:21:18.757: I/Process(1679): Sending signal. PID: 1679 SIG: 9
[/code]
Hata ne olabilir?